﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.User;
using PowerCreator.LMS.Web.Task;
using PowerCreator.LMS.Task.Entity;
using PowerCreator.LMS.ViewQuery;
using PowerCreator.LMS.Common.Utils;

public partial class sysadmin_TaskManager_AddTaskClass : System.Web.UI.Page
{
    //TaskClassRoomManag objTaskClassRoomManag = new TaskClassRoomManag();
    //EvaluateManag objEvaluateManag = new EvaluateManag();
    //TaskManag objTaskManag = new TaskManag();
    //User objUser = new User();
    TaskClassManag objTaskClassManag = new TaskClassManag();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int msgID = int.Parse(Request.Params["id"].ToString());
                ViewState["TaskID"] = msgID;
              

            }
            PageLoad();
        }
    }
    public void PageLoad()
    {
        //DataTable dtTaskClassRoom = objTaskClassRoomManag.Query("");
        //dpdlsTaskClassRoomt.DataSource = dtTaskClassRoom;
        //dpdlsTaskClassRoomt.DataTextField = "TaskCrName";
        //dpdlsTaskClassRoomt.DataValueField = "TaskCrID";
        //dpdlsTaskClassRoomt.DataBind();

        //DataTable dtTaskEvaluate = objEvaluateManag.Query("");
        //dpdlstTaskEvaluateName.DataSource = dtTaskEvaluate;
        //dpdlstTaskEvaluateName.DataTextField = "EvateName";
        //dpdlstTaskEvaluateName.DataValueField = "EvateID";
        //dpdlstTaskEvaluateName.DataBind();

        //DataTable dtTaskTeacher = objUser.QueryTeacher("", int.MaxValue, int.MaxValue);
        //dpdlstTaskTeacherID.DataSource = dtTaskTeacher;
        //dpdlstTaskTeacherID.DataTextField = "TeacherName";
        //dpdlstTaskTeacherID.DataValueField = "FKTeacherUserId";
        //dpdlstTaskTeacherID.DataBind();

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strErr = "";
        if (this.txtTaskCsName.Text == "")
        {
            strErr += "小组名称不能为空！\\n";
        }
        if (!TimeUtils.IsDateTime(txtTaskCsStartTime.Text))
        {
            strErr += "开始时间不是时间格式！\\n";
        }
        if (!TimeUtils.IsDateTime(txtTaskCsEndTime.Text))
        {
            strErr += "结束时间不是时间格式！\\n";
        }
        if (strErr != "")
        {
            Script.Alert(this, "msg", strErr);
            return;
        }
        int FKTaskID = int.Parse(ViewState["TaskID"].ToString());
			string TaskCsName=this.txtTaskCsName.Text;
			int TaskCsTrainingDays=0;
			DateTime TaskCsStartTime=DateTime.Parse(this.txtTaskCsStartTime.Text);
			DateTime TaskCsEndTime=DateTime.Parse(this.txtTaskCsEndTime.Text);
			int TaskCsTimeType=1;
			int TaskCsUserCount=0;
			int TaskCsAuditState=0;
           
          
			int TaskCsUserType=1;
            if (rdbtnStudent.Checked != true)
            {
                TaskCsUserType = 2;
            }
			int FKTaskCsTeacherID=10000;
			int FKTaskCsClassRoomID=0;
			DateTime TaskCsCreateTime=DateTime.Now;
            int FKTaskCsCreateID = 10000; ;

			TaskClass model=new TaskClass();
			model.FKTaskID=FKTaskID;
			model.TaskCsName=TaskCsName;
			model.TaskCsTrainingDays=TaskCsTrainingDays;
			model.TaskCsStartTime=TaskCsStartTime;
			model.TaskCsEndTime=TaskCsEndTime;
			model.TaskCsTimeType=TaskCsTimeType;
			model.TaskCsUserCount=TaskCsUserCount;
			model.TaskCsAuditState=TaskCsAuditState;
			model.TaskCsUserType=TaskCsUserType;
			model.FKTaskCsTeacherID=FKTaskCsTeacherID;
			model.FKTaskCsClassRoomID=FKTaskCsClassRoomID;
			model.TaskCsCreateTime=TaskCsCreateTime;
			model.FKTaskCsCreateID=FKTaskCsCreateID;
            objTaskClassManag.AddNew(model);
            Script.RedirectURL("TaskClassManager.aspx?id=" + ViewState["TaskID"].ToString());
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        Script.RedirectURL("TaskClassManager.aspx?id=" + ViewState["TaskID"].ToString());
    }

}
